package logic

import (
	"log"
	"mssgserver/constant"
	"mssgserver/db"
	"mssgserver/server/common"
	"mssgserver/server/game/model"
	"mssgserver/server/game/model/data"
)

var DefaultSkillController = &skillController{}

type skillController struct {
}

/*
*
获取技能
*/
func (s *skillController) GetSkills(rid int) ([]model.Skill, error) {
	skillList := make([]data.Skill, 0)
	skill := &data.Skill{}
	err := db.Engine.Table(skill).Where("rid=?", rid).Find(&skillList)
	if err != nil {
		log.Println("GetSkill技能查询出错", err)
		return nil, common.New(constant.DBError, "GetSkill技能查询出错")
	}
	skills := make([]model.Skill, 0)
	for _, single := range skillList {
		skills = append(skills, single.ToModel().(model.Skill))
	}
	return skills, nil
}
